<% @main_header = "#{link_to('Ptrack:', '/')} #{@project.name if @project}: Notes" %>

<div id="info" class='column span-8' style="width: 100%;">
	<div style="width: 80%; float: left;">
		<h3><%= link_to "Create New Note", :action=> :new %></h3>
	</div>
	<div style="width: 20%; float: left; text-align: right;">
		<%= @viewType.nil? ? "List View" : link_to("List View", {:action => "index"}) %> |
		<%= (@viewType == "expanded") ? "Expanded View" : link_to( "Expanded View", {:action => "index", "view" => "expanded" } ) %>
	</div>
</div>
<div style="float: left; width: 100%;">
  	<fieldset>

    <% unless @project %>
      <legend>All Notes</legend>
    <% else %>
      <legend>Project Notes</legend>
    <% end %>

	<table>
	<tr>
		<td style="font-weight: bold;">
			Title
		</td>
        <% unless @project %>
		<td style="font-weight: bold;">
			Project
		</td>
        <% end %>
		<td style="font-weight: bold;">
			From
		</td>
		<td style="font-weight: bold;">
			Contact
		</td>
		<td style="font-weight: bold;">
			Date at Time
		</td>
		<td></td>
		<td></td>
		<td></td>
	</tr>
	<tr>
		<td colspan="7">
			<hr>
		</td>
	</tr>
	<% for note in @notes %>
  	<tr>
	<td><%= link_to h(note.title), {:action => "show", :id => note } %></td>

	<% unless @project %>
	      <td><%=note.project.nil? ? "Project Not Specified" : link_to(h(note.project.name), {:controller => "projects", :id => note.project.id}) %></td>
	<% end %>
	<td> <%= note.user.nil? ? "Anonymous" : link_to( h(note.user.full_name), {:controller => "users", :action => "show", :id => note.user.id}) %></td>
	
	
	
	<td>
		<% if note.contacts.length == 0 %>
		Contacts Not Specified
		<% else %>
			<% for c in note.contacts %>
				<% if c.id == note.contacts.find(:first).id %><%= link_to( h(c.full_name), {:controller => "contacts", :action => "show", :id => c.id} ) %><% else %>, <%= link_to( h(c.full_name), {:controller => "contacts", :action => "show", :id => c.id} ) %><% end %>
			<% end %>
		<% end %>
	</td>
	
	
	<td><%=note.updated_at.strftime("%d.%m.%Y at %H:%M") %></td>
	<td><%= link_to "Edit", :action => "edit", :id => note%></td>
	<td><%= link_to("Delete", {:action => "destroy", :id => note}, :method => :delete, :confirm => "Are you sure want to delete the note with title #{note.title} ?")%></td>
	</tr>

	<% end %>
	</table>
  	</fieldset>
  </div>